//
//  LYDSegmentHeader.m
//  ZeegingLottery
//
//  Created by 李曌 on 2018/11/1.
//  Copyright © 2018 蒂埃里. All rights reserved.
//

#import "LYDSegmentHeader.h"

#define SCREEN_WIDTH   ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT  ([[UIScreen mainScreen] bounds].size.height)

@interface LYDSegmentHeader ()

//标志样式
@property (nonatomic, assign) LYDSegmentHeaderStyle headerType;

@property (nonatomic, strong) NSArray *titleArray;

@property (nonatomic, strong) UIScrollView *titleScroll;


@end

@implementation LYDSegmentHeader

- (instancetype)initWithFrame:(CGRect)frame TitleArray:(NSArray *)titles
{
    return [self initWithFrame:frame TitleArray:titles Type:LYDSegmentHeaderStyleDefault];
}

- (instancetype)initWithFrame:(CGRect)frame TitleArray:(NSArray *)titles Type:(LYDSegmentHeaderStyle )style
{
    self = [super initWithFrame:frame];
    if (self) {
        self.headerType = style;
        self.titleArray = [titles mutableCopy];
        
        
        
    }
    return self;
}


- (void)CreatViewWith:(LYDSegmentHeaderStyle)style
{
    _maxTitle = 5;
    
    
    switch (style) {
        case LYDSegmentHeaderStyleDefault:
            [self DefaultCreat];
            break;
        case LYDSegmentHeaderStyleLine:
            [self DefaultCreat];
            break;
        case LYDSegmentHeaderStyleArrow:
            [self DefaultCreat];
            break;
        case LYDSegmentHeaderStyleSlide:
            [self DefaultCreat];
            break;
        case LYDSegmentHeaderStyleSlideImage:
            [self DefaultCreat];
            break;
            
        default:
            break;
    }
    
    
}

- (void)DefaultCreat
{
    _titleScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [self addSubview:self.titleScroll];
    
    NSInteger count = _titleArray.count;
    CGFloat btnW;
    if (count <= 5) {
        btnW = SCREEN_WIDTH/count;
    }
    for (int i = 0 ; i < count; i++) {
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        NSString *title = _titleArray[i];
        [button setTitle:title forState:UIControlStateNormal];
        [button setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        [button setTitleColor:self.selectColor forState:UIControlStateSelected];
        
        
    }
    
    
}














@end
